// 获取具体地址
/**
 * @param {Object} types 查询地址的类型，当您的keywords和types都是空时，默认指定types为120000（商务住宅）&150000（交通设施服务）更多类型https://lbs.amap.com/api/webservice/download
 * @param {Object} keywords 查询关键字
 * 
 */
export function getAddr( keywords:string, city:string ) {
	return new Promise((resolve, reject) => {
		uni.request({
			url: "https://restapi.amap.com/v3/place/text",
			data: {
				key: "d58c05fcffe60446a934bc0f24de110a",
				types: '120000',
				keywords,
				city: '杭州市'
			},
			success: res => {
                console.log('小区接口请求成功 :>> ');
                console.log('res :>> ', res);
				resolve(res)
			},
			fail: err => {
                console.log('小区接口请求失败:>> ');
				reject(err)
			}
		})
	})
}

export function getAddressInfo(coord:string) {
	return new Promise((resolve, reject) => {
		 uni.request({
			url: "https://restapi.amap.com/v3/geocode/regeo",
			data: {
				key: "d58c05fcffe60446a934bc0f24de110a",
				location: coord,
			},
			success: res => {
                console.log('逆地址解析接口请求成功 :>> ');
                console.log('res :>> ', res);
				resolve(res)
			},
			fail: err => {
                console.log('逆地址解析接口请求失败:>> ',err);
				reject(err)
			}
		})
	})
}